package org.one.stone.soup.grfxML.plugin.swing;

import javax.swing.filechooser.FileView;

/*
 * Wet-Wired.com Library Version 2.1
 *
 * Copyright 2000-2001 by Wet-Wired.com Ltd.,
 * Portsmouth England
 * This software is OSI Certified Open Source Software
 * This software is covered by an OSI approved open source licence
 * which can be found at http://www.onestonesoup.org/OSSLicense.html
 */

/**
 * @author nikcross
 *
 */

// TODO
public class SimpleFileFilter extends javax.swing.filechooser.FileFilter {
	private String description;
	private String[] mask;
/**
 * Insert the method's description here.
 * Creation date: (07/02/03 18:26:24)
 * @param mask java.lang.String
 * @param description java.lang.String
 */
public SimpleFileFilter(String mask, String description)
{
	this(new String[]{mask},description);
}

public SimpleFileFilter(String[] mask, String description)
{
	this.mask = mask;
	this.description = description;
}
	/**
	 * Whether the given file is accepted by this filter.
	 */
public boolean accept(java.io.File f) {

	if(mask.equals("*"))
		return true;
	else if(f.isDirectory())
		return true;
	else
	{
		for(int loop=0;loop<mask.length;loop++)
		{
			if(org.one.stone.soup.stringhelper.FileNameHelper.getExt(f.getName()).toLowerCase().equals(mask[loop].toLowerCase()))
			{
				return true;
			}
		}
	}
	
	return false;
}
	/**
	 * The description of this filter. For example: "JPG and GIF Images"
	 * @see FileView#getName
	 */
public java.lang.String getDescription() {
	return description;
}
}
